﻿using AutoMapper;
using ProjectManageSystemApi.DbEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ProjectManageSystemApi.Services.Impl
{
    public class BuildingSiteBillImagesServices : ServicesBase, IBuildingSiteBillImagesServices
    {
        public BuildingSiteBillImagesServices(IFreeSql fsql, IMapper mapper) : base(fsql, mapper) { }
        public bool Add(uint billId, List<string> images)
        {
            var datas = images
                .Where(x => !string.IsNullOrWhiteSpace(x))
                .Select(x => new BuildingSiteBillImages
                {
                    BuildingSiteBillId = billId,
                    Image = x
                }).ToList();
            return _fsql.Insert<BuildingSiteBillImages>(datas).ExecuteAffrows() >= datas.Count();
        }
        public void DelAll(uint billId) 
        {
            _fsql.Delete<BuildingSiteBillImages>().Where(x=>x.BuildingSiteBillId == billId).ExecuteAffrows();
        }
    }
}
